extends Node2D

var player
var playerLife
var enemyLife
var timer
func _ready():
	player = get_tree().current_scene.get_node("player")
	playerLife = get_tree().current_scene.get_node("playerLife")
	enemyLife = get_tree().current_scene.get_node("enemyLife")
	timer = get_tree().current_scene.get_node("Timer")
	inflate_skills()
	connect_skills()
	connect_timer()
	pass

func connect_skills():
	$btn1.connect("pressed",enemyLife,"_on_enemy_hurt",[Global.chongwuInfo.current_skill["0"].weili])
	$btn2.connect("pressed",enemyLife,"_on_enemy_hurt",[Global.chongwuInfo.current_skill["1"].weili])
	$btn3.connect("pressed",enemyLife,"_on_enemy_hurt",[Global.chongwuInfo.current_skill["2"].weili])
	$btn4.connect("pressed",enemyLife,"_on_enemy_hurt",[Global.chongwuInfo.current_skill["3"].weili])
	pass
	
func connect_timer():
	$btn1.connect("pressed",timer,"_on_player")
	$btn2.connect("pressed",timer,"_on_player")
	$btn3.connect("pressed",timer,"_on_player")
	$btn4.connect("pressed",timer,"_on_player")
	
func inflate_skills():
	$btn1/name.text = Global.chongwuInfo.current_skill["0"].name
	$btn1/weili.text = "威力"+str(Global.chongwuInfo.current_skill["0"].weili)
	$btn1/pp.text = "pp"+str(Global.chongwuInfo.current_skill["0"].pp)
	
	$btn2/name.text = Global.chongwuInfo.current_skill["1"].name
	$btn2/weili.text = "威力"+str(Global.chongwuInfo.current_skill["1"].weili)
	$btn2/pp.text = "pp"+str(Global.chongwuInfo.current_skill["1"].pp)
	
	$btn3/name.text = Global.chongwuInfo.current_skill["2"].name
	$btn3/weili.text = "威力"+str(Global.chongwuInfo.current_skill["2"].weili)
	$btn3/pp.text = "pp"+str(Global.chongwuInfo.current_skill["2"].pp)
	
	$btn4/name.text = Global.chongwuInfo.current_skill["3"].name
	$btn4/weili.text = "威力"+str(Global.chongwuInfo.current_skill["3"].weili)
	$btn4/pp.text = "pp"+str(Global.chongwuInfo.current_skill["3"].pp)
	pass
	
func _on_cancel_pressed():
	$taopao.hide()
	pass


func _on_ok_pressed():
	$AnimationPlayer.play("tao")
	pass


func _on_AnimationPlayer_animation_finished(anim_name):
	if anim_name == "tao":
		get_tree().change_scene("res://Scene.tscn")
	pass

func _on_run_pressed():
	$taopao.show()
	pass

func _on_failed_ok_pressed():
	get_tree().change_scene("res://Scene.tscn")
	pass


func _on_win_btn_pressed():
	get_tree().change_scene("res://Scene.tscn")
	pass


func _on_daoju_pressed():
	$btn1.hide()
	$btn2.hide()
	$btn3.hide()
	$btn4.hide()
	$daojulan.show()
	pass 


func _on_attack_pressed():
	$btn1.show()
	$btn2.show()
	$btn3.show()
	$btn4.show()
	$daojulan.hide()
	pass # Replace with function body.
